package com.ktm.gecco.crawler.boche.service.impl;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ktm.gecco.crawler.boche.entity.BocheCar;
import com.ktm.gecco.crawler.boche.mapper.BocheCarMapper;
import com.ktm.gecco.crawler.boche.service.BocheCarService;
import com.ktm.gecco.crawler.main.service.ScheduleJobService;
import com.ktm.gecco.crawler.main.service.base.BaseUserLog;
/**
 * @desc 类功能描述：汽车服务层
 * @author ShiYuanPeng
 * @createTime 2016年8月11日 上午10:19:50
 *
 * @version V2.0
 */
@Service
public class BocheCarServiceImpl extends BaseUserLog implements BocheCarService {

    private static final Logger log = Logger.getLogger(ScheduleJobService.class);

    @Autowired
    private BocheCarMapper bocheCarMapper;

    public static long count =0;

    @Override
    public BocheCar getBocheCarByVin(String vin) {
        try {
            BocheCar car = bocheCarMapper.getBocheCarByVin(vin);
            return car;
        } catch (Exception e) {
            System.out.println("根据vin查询数据失败");
            log.info("根据vin查询数据失败");
        }
        return null;
    }

    @Override
    public void batchSaveBoche(BocheCar dxhCar) {
        try {
            bocheCarMapper.batchSaveBocheCar(dxhCar);

            System.out.println("Save Succiful");
            this.saveUserLog("博车网",dxhCar.getCarname()+dxhCar.getVin()+"采集数据保存成功");
            count++;
        } catch (Exception e) {
            System.out.println("博车网数据保存失败");
            log.info("博车网公示区数据保存失败");
        }
    }

}
